home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / c / strtol.man < prev    next >
Encoding:
Text File  |  1989-03-22  |  2.8 KB  |  70 lines

  1. ' Copyright 1989 Regents of the University of California
  2. ' Permission to use, copy, modify, and distribute this
  3. ' documentation for any purpose and without fee is hereby
  4. ' granted, provided that this notice appears in all copies.
  5. ' The University of California makes no representations about
  6. ' the suitability of this material for any purpose.  It is
  7. ' provided "as is" without express or implied warranty.
  8. ' $Header: /sprite/src/lib/c/stdlib/RCS/strtol.man,v 1.1 89/01/05 17:59:48 ouster Exp $ SPRITE (Berkeley)
  9. .so \*(]ltmac.sprite
  10. .HS strtol cmds
  11. .BS
  12. .SH NAME
  13. strtol, strtoul \- Convert character string to integer
  14. .SH SYNOPSIS
  15. .nf
  16. \fB#include <stdlib.h>
  17.  
  18. \fBlong int
  19. \fBstrtol(\fIstring\fR, \fIendPtr\fR, \fIbase\fR)
  20.  
  21. \fBunsigned long int
  22. \fBstrtoul(\fIstring\fR, \fIendPtr\fR, \fIbase\fR)
  23. .SH ARGUMENTS
  24. .AS "char *" endPtr
  25. .AP char *string in
  26. String containing ASCII representation of integer.
  27. .AP char **endPtr out
  28. If not \fBNULL\fR, gives address of pointer to fill in with address of
  29. first character in \fIstring\fR following integer.
  30. .AP int base in
  31. Base to use for conversion;  see below for explanation.  Must be
  32. between 0 and 36, inclusive.
  33. .BE
  34.  
  35. .SH DESCRIPTION
  36. .PP
  37. The \fBstrtol\fR and \fBstrtoul\fR procedures convert a character
  38. string to its corresponding integer representation and return the
  39. integer value.  Both procedures
  40. expect \fIstring\fR to point to a sequence of digits, optionally preceded
  41. by any amount of white space (as defined by the \fBisspace\fR procedure).
  42. \fBStrtol\fR also permits the digits to be preceded immediately by a
  43. minus sign, in which case the result is a negative integer.
  44. .PP
  45. If \fIbase\fR is between 2 and 36, inclusive, then the permissible
  46. ``digits'' of the string consist of the first \fIbase\fR characters
  47. in the set \fB0\fR through \fB9\fR and \fBa\fR through \fBz\fR
  48. (or \fBA\fR through \fBZ\fR).  The integer result will be calculated
  49. using \fIbase\fR as the radix for conversion.  If the value of \fIbase\fR
  50. is 16, then the characters \fB0x\fR or \fB0X\fR may precede the digits,
  51. following the sign if it is present.
  52. .PP
  53. If \fIbase\fR is 0, then the radix for conversion is chosen based on
  54. the initial digits of the number.  If the initial digits are \fB0x\fR
  55. or \fB0X\fR, then base 16 will be used for conversion;  otherwise if
  56. the first digit is \fB0\fR then base 8 will be used for conversion;
  57. otherwise base 10 will be used.
  58. .PP
  59. \fBStrtol\fR and \fBstrtoul\fR convert as many characters as possible
  60. from \fIstring\fR, and return in \fI*endPtr\fR the address of the first
  61. character not forming a valid portion of the number.  If no conversion
  62. could be performed (\fIstring\fR was empty, or did not point to a
  63. number in the expected form), then \fIstring\fR will be stored in
  64. \fI*endPtr\fR and zero is returned.
  65.  
  66. .SH KEYWORDS
  67. base, convert, integer, radix, string
  68.